import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_250303/pages/home/home_page.dart';
import 'package:flutter_250303/pages/tab_page.dart';
import 'package:flutter_250303/pages/web_view_page.dart';

class Routes {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case RoutePath.tab:
        return pageRoute(TabPage(), settings: settings);
      case RoutePath.webViewPage:
        return pageRoute(WebViewPage(title: "哪里route来"), settings: settings);
    }
    return pageRoute(Scaffold(
      body: SafeArea(
        child: Center(
          child: Text("route path ${settings.name} 不存在"),
        ),
      ),
    ));
  }

  static MaterialPageRoute pageRoute(Widget page,
      {RouteSettings? settings,
      bool? fullscreenDialog,
      bool? maintainState,
      bool? allowSnapshotting}) {
    return MaterialPageRoute(
      builder: (context) {
        return page;
      },
      settings: settings,
      fullscreenDialog: fullscreenDialog ?? false,
      maintainState: maintainState ?? true,
      allowSnapshotting: allowSnapshotting ?? true,
    );
  }
}

// 路由地址
class RoutePath {
  static const String tab = "/";
  static const String webViewPage = "/web_view_page";
}
